Better messages for "JSON node should (not) contain"#33
Open
jdeniau wants to merge 1 commit intosoyuka:mainfrom
Open
Better messages for "JSON node should (not) contain"#33jdeniau wants to merge 1 commit intosoyuka:mainfrom
jdeniau wants to merge 1 commit intosoyuka:mainfrom
Conversation
c41fecc to
818c276
Compare
Jean-Beru
reviewed
Jun 4, 2024
| $this->assertContains( | ||
| $text, | ||
| (string) $actual, | ||
| 'The node "'.$node.'" does not contain the expected text "'.$text.'" (found "'.$printedActual.'")' |
Collaborator
There was a problem hiding this comment.
The node '%s' should contain '%s', but it is '%s'. is more concise. WDYT ?
| $actual = $this->inspector->evaluate($json, $node); | ||
|
|
||
| $this->assertContains($text, (string) $actual); | ||
| $printedActual = \strlen($actual) > 50 ? substr($actual, 0, 50).'[…]' : $actual; |
Collaborator
There was a problem hiding this comment.
Truncating the value might make debugging more difficult.
Comment on lines
+261
to
+267
| $printedActual = \strlen($actual) > 50 ? substr($actual, 0, 50).'[…]' : $actual; | ||
|
|
||
| $this->assertNotContains( | ||
| $text, | ||
| (string) $actual, | ||
| 'The node "'.$node.'" does contain "'.$text.'" while it should not (found "'.$printedActual.'")' | ||
| ); |
Collaborator
There was a problem hiding this comment.
(same comments as previous)
Jean-Beru
reviewed
Jun 4, 2024
| (string) $actual, | ||
| 'The node "'.$node.'" does contain "'.$text.'" while it should not (found "'.$printedActual.'")' | ||
| ); | ||
| } |
Collaborator
There was a problem hiding this comment.
Can you add a unit test too ?
Author
|
It does, but the value when you use "contain" might be a huge bloc of text. Maybe we can set the limit to 200 or 500 though.
…-------- Message d'origine --------
Le 04/06/2024 22:00, Hubert Lenoir a écrit :
@Jean-Beru commented on this pull request.
---------------------------------------------------------------
In [src/Context/JsonContext.php](#33 (comment)):
> @@ -226,7 +226,13 @@ public function theJsonNodeShouldContain($node, $text): void
$actual = $this->inspector->evaluate($json, $node);
- $this->assertContains($text, (string) $actual);
+ $printedActual = \strlen($actual) > 50 ? substr($actual, 0, 50).'[…]' : $actual;
+
+ $this->assertContains(
+ $text,
+ (string) $actual,
+ 'The node "'.$node.'" does not contain the expected text "'.$text.'" (found "'.$printedActual.'")'
The node '%s' should contain '%s', but it is '%s'. is more concise. WDYT ?
---------------------------------------------------------------
In [src/Context/JsonContext.php](#33 (comment)):
> @@ -226,7 +226,13 @@ public function theJsonNodeShouldContain($node, $text): void
$actual = $this->inspector->evaluate($json, $node);
- $this->assertContains($text, (string) $actual);
+ $printedActual = \strlen($actual) > 50 ? substr($actual, 0, 50).'[…]' : $actual;
Truncating the value might make debugging more difficult.
---------------------------------------------------------------
In [src/Context/JsonContext.php](#33 (comment)):
> + $printedActual = \strlen($actual) > 50 ? substr($actual, 0, 50).'[…]' : $actual;
+
+ $this->assertNotContains(
+ $text,
+ (string) $actual,
+ 'The node "'.$node.'" does contain "'.$text.'" while it should not (found "'.$printedActual.'")'
+ );
(same comments as previous)
—
Reply to this email directly, [view it on GitHub](#33 (review)), or [unsubscribe](https://github.com/notifications/unsubscribe-auth/AAKVNRPOVMPIXY3VTD26TATZFYMFLAVCNFSM6AAAAABIYFSHBCVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDAOJXGI3TOMZZGE).
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Collaborator
Sure ! We can keep this value uncut for now (like in other contexts) and create an other PR to truncate it. Maybe using the verbosity ? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See #31
Added better message for
theJsonNodeShouldContain:and for
theJsonNodeShouldNotContain